package com.lonely.inventory.enums;

import com.lonely.common.exception.BusinessException;
import lombok.Getter;

/**
 * @author : 黄志标
 * @date: 2025/9/18 11:45
 * @description: 库存档案相关枚举
 */
public class StorageArchiveEnum {


    /**
     * 库存类型枚举
     */
    @Getter
    public enum StorageTypeEnum {

        /**
         * 备货库位
         */
        STOCK_UP_STORAGE("BH", "备货库位"),

        /**
         * 样衣库位
         */
        SAMPLE_GARMENT_STORAGE("YY", "样衣库位"),

        /**
         * 尾货库位
         */
        SURPLUS_STOCK_STORAGE("WH", "尾货库位");


        /**
         * 库位类型code
         */
        private final String storageTypeCode;

        /**
         * 库位类型名称
         */
        private final String storageTypeName;

        StorageTypeEnum(String storageTypeCode, String storageTypeName) {
            this.storageTypeCode = storageTypeCode;
            this.storageTypeName = storageTypeName;
        }

        /**
         * 根据库位类型code获取库位类型枚举
         *
         * @param storageTypeCode
         * @return
         */
        public static StorageTypeEnum getInstanceByStorageTypeCode(String storageTypeCode) {
            for (StorageTypeEnum value : StorageTypeEnum.values()) {
                if (value.getStorageTypeCode().equals(storageTypeCode)) {
                    return value;
                }
            }
            throw new BusinessException(String.format("%s 库位类型不存在", storageTypeCode));
        }
    }


    /**
     * 库位前缀枚举
     */
    @Getter
    public enum StoragePrefixEnum {

        A,
        B,
        C,
        D,
        E,
        F,
        G;


        /**
         * 根据库位类型code获取库位类型枚举
         *
         * @param storagePrefix
         * @return
         */
        public static StoragePrefixEnum getInstanceByStorageTypeCode(String storagePrefix) {
            for (StoragePrefixEnum value : StoragePrefixEnum.values()) {
                if (value.name().equals(storagePrefix)) {
                    return value;
                }
            }
            throw new BusinessException(String.format("%s 库位前缀不存在", storagePrefix));
        }
    }


}
